<?php



include "dbconfig.php";
function connect(){
    //ham dung de ket noi den CSDL
    global $host;
    global $databaseName;
    global $userName;
    global $password;
    
    $connection = mysql_connect($host,$userName,$password);
    if(!$connection){
        echo "connect to $host fail !";
    }
    $db = mysql_select_db($databaseName);
    if (!$db){
        echo "connect to $databaseName fail !";
    }
}
function disconnect(){
    //ham nay dung de dong ket noi den CSDL
    $connection = null;
}
function executeQuery($sql){
    //ham nay dung de thuc thi cac cau lenh SELECT
    connect();
    $resultset=mysql_query($sql);
    disconnect();
    return $resultset;
}
function executeNonQuery($sql){
    //ham nay dung de thuc thi 3 cau lenh INSERT/UPDATE/DELETE
    connect();
    mysql_query($sql);
    disconnect();
}
?>